package com.example.streaming

import org.apache.flink.api.scala.createTypeInformation
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment

/**
 * @author lbq
 * @date 2022/3/14 23:07
 * @version 1.0
 */
object WordCountScalaStreaming {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val stream = env.socketTextStream("aliyun", 7777, '\n')
    val result = stream.flatMap(_.split("\\s+")).map((_, 1)).keyBy(0).sum(1)

    result.print()

    env.execute(WordCountScalaStreaming.getClass.getName)
  }
}
